package com.helloandroid.activitys

import android.view.MotionEvent
import android.widget.TextView
import com.helloandroid.R
import com.helloandroid.base.BaseActivity
import com.helloandroid.view.PgData
import com.helloandroid.view.PgView

class BMIInfoActivity : BaseActivity() {

    lateinit var tvValue:TextView
    lateinit var tvState:TextView
    lateinit var pgBMI:PgView

    override fun getContentViewResId() = R.layout.activity_bmiinfo

    override fun initView() {
        tvValue = findViewById(R.id.tvValue)
        tvState = findViewById(R.id.tvState)
        pgBMI = findViewById(R.id.pgBMI)
        findBtn(R.id.ibBack).setOnClickListener { finish() }
    }

    override fun initData() {
        val bmi  = intent.getFloatExtra("bmi",20.0f)
        tvState.text = intent.getStringExtra("bmi_state")
        tvValue.text = "$bmi"

        //
        val bmiData = PgData(
                min = 10f,
                max = 40f,
                mid1 = BodyInfoActivity.BMI_Min,
                mid2 = BodyInfoActivity.BMI_Max,
                mid3 = BodyInfoActivity.BMI_Super,
                cur = bmi,
                texts = arrayListOf("偏瘦","理想","偏胖","肥胖")
        )
        pgBMI.updatePgData(bmiData)
    }
}